% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/popup_from_any.R
\name{popup_from_any}
\alias{popup_from_any}
\title{Map popups - Simple map popup from a data.table or data.frame, one point per row}
\usage{
popup_from_any(
  x,
  column_names = names(x),
  labels = column_names,
  n = "all",
  testing = FALSE
)
}
\arguments{
\item{x, }{a data table or data frame}

\item{column_names}{default is all, or a vector of column names from x to use.
If some of column_names requested are not found in names(x),
a warning is given and NA values returned for those names not in x.
If some of names(x) not requested by column_names, they are left out.}

\item{labels}{default is column_names - vector used to label
the elements in the popup. Must be same length as column_names}

\item{n}{Show the first n columns of mypoints, in popup. "all" means all of them.}

\item{testing}{can set to TRUE while testing function}
}
\value{
A vector of strings, one per row or map point,
with a line break separating column elements
}
\description{
Creates popup vector leaflet::addCircles or leaflet::addPopups can use.
}
\details{
Each popup is made from one row of the data.frame.
Each popup has one row of text per column of the data.frame
}
\examples{
 
 dat <- data.table(
   RegistryId = c("110071102551", "110015787683"),
   FacilityName = c("USDOI FWS AK MARITIME NWR etc", "ADAK POWER PLANT"),
   LocationAddress = c("65 MI W. OF ADAK NAVAL FACILITY", "100 HILLSIDE BLVD"),
   CityName = c("ADAK", "ADAK"),
   CountyName = c("ALEUTIAN ISLANDS", "ALEUTIANS WEST"),
   StateAbbr = c("AK", "AK"),
   ZipCode = c("99546", "99546"),
   FIPSCode = c("02010", "02016"),
   lat = c(51.671389,51.8703), lon = c(-178.051111, -176.659),
   SupplementalLocation = c(NA_character_,NA_character_))
 
 ## add popups only
 leaflet::leaflet(dat) |> leaflet::addTiles() |> leaflet::addPopups(popup = popup_from_any(dat))
 
 ## add circles with clickable popups
 leaflet::leaflet(dat) |> leaflet::addTiles() |> leaflet::addCircles(popup = popup_from_any(dat))
 
 ## convert to data frame, works the same way 
 dat_df <- as.data.frame(dat_df)
 leaflet::leaflet(dat) |> leaflet::addTiles() |> leaflet::addCircles(popup = popup_from_any(dat))
  
}
